package cn.yuanqiao.web.controller.archive.shuzihua;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import cn.yuanqiao.archive.shuzihua.domain.ArchiveEnroll;
import cn.yuanqiao.archive.shuzihua.service.IArchiveEnrollService;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.enums.BusinessType;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 档案登记记录Controller
 * 
 * @author xy
 * @date 2024-09-12
 */
@RestController
@RequestMapping("/archive/archiveEnroll")
public class ArchiveEnrollController extends BaseController
{
    @Autowired
    private IArchiveEnrollService archiveEnrollService;

    /**
     * 查询档案登记记录列表
     */
//    @RequiresPermissions("archive:archiveEnroll:list")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveEnroll archiveEnroll)
    {
        startPage();
        List<ArchiveEnroll> list = archiveEnrollService.selectArchiveEnrollList(archiveEnroll);
        return getDataTable(list);
    }

    /**
     * 导出档案登记记录列表
     */
//    @RequiresPermissions("archive:archiveEnroll:export")
    @Log(title = "档案登记记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveEnroll archiveEnroll)
    {
        List<ArchiveEnroll> list = archiveEnrollService.exportArchiveEnrollList(archiveEnroll);
        ExcelUtil<ArchiveEnroll> util = new ExcelUtil<ArchiveEnroll>(ArchiveEnroll.class);
        util.exportExcel(response, list, "档案登记记录数据");
    }

    /**
     * 获取档案登记记录详细信息
     */
//    @RequiresPermissions("archive:archiveEnroll:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(archiveEnrollService.selectArchiveEnrollById(id));
    }

    /**
     * 新增档案登记记录
     */
//    @RequiresPermissions("archive:archiveEnroll:add")
    @Log(title = "档案登记记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveEnroll archiveEnroll)
    {
        return toAjax(archiveEnrollService.insertArchiveEnroll(archiveEnroll));
    }

    /**
     * 修改档案登记记录
     */
//    @RequiresPermissions("archive:archiveEnroll:edit")
    @Log(title = "档案登记记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveEnroll archiveEnroll)
    {
        return toAjax(archiveEnrollService.updateArchiveEnroll(archiveEnroll));
    }

    /**
     * 删除档案登记记录
     */
//    @RequiresPermissions("archive:archiveEnroll:remove")
    @Log(title = "档案登记记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(archiveEnrollService.deleteArchiveEnrollByIds(ids));
    }
}
